<div id="sidebar">
  <div id="search" class="widget">
    <div id="search-wrapper">
      <form method="get" id="search-form" action="http://www.google.com/search" target="_blank">
        <input type="text" value="Search..." onfocus="if (this.value == 'Search...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search...';}" name="as_q" id="s" />
        <input type="submit" id="search-submit" value="" />
        <input name="as_sitesearch" value="{{blog.domain}}" type="hidden">
      </form>
    </div>
  </div>
  <div id="text" class="widget">
    <h4>公告</h4>
    <div class="textwidget">
      <p>{{blog.blognotice}}</p>
    </div>
  </div>
  <div id="recent-posts" class="widget">
    <h4>最近文章</h4>
    <ul>
      {% for entry in blog.recentposts %}
      <li><a href="/{{entry.link|escape}}" title="{{entry.title|escape}}">{{entry.title|escape}}({{entry.readtimes}})</a></li>
      {%endfor%}
    </ul>
  </div>
  <!--
  <div id="recent-comments" class="widget">
    <h4>近期评论</h4>
    <ul id="recentcomments">
      {% for comment in recent_comments %}
      <li class="rc_item">
        <div class="rc_avatar"><img src='{{comment.gravatar_url}}' class='avatar avatar-28 photo round' height='28' width='28' /></div>
        <div class="rc_info"><span class="author_name">{%if comment.weburl %}<a href="{{comment.weburl}}" target="_blank">{{comment.author}}</a>{% else %}{{comment.author}}{%endif%}</span> | {{comment.date|datetz:"H:i, m-d"}}</div>
        <div class="rc_excerpt"><a href="/{{comment.entry.link|escape}}#comment-{{comment.key.id}}" title="发表于 {{comment.entry.title|escape}}">{{comment.shortcontent}}...</a></div>
      </li>
      {%endfor%}
    </ul>
  </div>
  -->
  <div id="categories" class="widget">
    <h4>分类目录</h4>
    <ul>
      {%for cate in categories%}
      {% if not cate.parent_cat %}
      <li class="cat-item"><a href="/category/{{cate.slug}}" title="查看 {{cate.name}} 下的全部文章">{{cate.name}}</a>({{cate.count}})</li>
      {% if cate.children%} 
      {%for cate in cate.children%}
      <ul class='children'>
        <li class="cat-item"><a href="/category/{{cate.slug}}" title="查看 {{cate.name}} 下的全部文章">{{cate.name}}</a>({{cate.count}})</li>
      </ul>
      {%endfor%} 
      {%endif%} 
      {%endif%}    
      {%endfor%}
    </ul>
  </div>
  <div id="archives" class="widget">
    <h4>文章归档</h4>
    <ul>
      {%for archive in archives%}
      <li><a href="/{{archive.year}}/{{archive.month}}" title="{{archive.year}}年{{archive.month}}月的文章">{{archive.year}}年{{archive.month}}月</a>({{archive.entrycount}})</li>
      {%endfor%}
    </ul>
  </div>
  <div id="tag_cloud" class="widget widget_tag_cloud">
    <h4>标签</h4>
    <div class="tagcloud"> {% if alltags %}
      {% for t in alltags %} <a style="font-size:{{ t.tagcount|add:9 }}px;" title="{{ t.tagcount }}篇文章" 
						href="/tag/{{t.tag|urlencode}}">{{t.tag}}</a> {%endfor%}
      {% endif %} </div>
  </div>
  <div id="linkcat" class="widget">
    <h4>友情链接</h4>
    <ul class='xoxo blogroll'>
      {%for link in blogroll%}
      <li><a href="{{link.href}}" title="{{link.linktext}}" target="_blank">{{link.linktext}}</a></li>
      {%endfor%}
    </ul>
  </div>
  <div id="googlead">
	<script type="text/javascript">
	google_ad_client = "pub-6293971471163289";
	google_ad_slot = "1503208580";
	google_ad_width = 200;
	google_ad_height = 200;
	</script>
	<script type="text/javascript"
	src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
	</script>
  </div>
  <div id="meta" class="widget">
    <h4>功能</h4>
    <ul>
      <li><a rel="external nofollow" id="feedrss" title="订阅这个博客的文章" href="{{ blog.feedurl }}">文章<abbr title="Really Simple Syndication">RSS</abbr></a></li>
      <li><a rel="external nofollow" id="feedrsscomments" title="订阅这个博客的评论" href="{{ blog.feedurl }}/comments">评论<abbr title="Really Simple Syndication">RSS</abbr></a></li>
    </ul>
  </div>
</div>
<script type="text/javascript">
        $(".tagcloud a").each(function (i) {
            this.style.color = randomColor()
        });
        function randomColor() {
            var arrHex = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F"];
            var strHex = "#";
            var index;
            for (var i = 0; i < 6; i++) {
                index = Math.round(Math.random() * 15);
                strHex += arrHex[index];
            }
            return strHex;
        }
	</script>
